
$(function(){
	$(".mkbanner li:eq(2)").addClass("active");
	
	$("#label li span").click(function(){
		var labelId = $(this).attr("data");
		$.post(ctx+"/label/delete",
				{labelId:labelId},
				function(result){
					alert(commonSuccess);
					window.location.href = location.href;
				},"json");
	});
	

    $('#defaultForm').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
        	labelName:{
            	validators: {
                    notEmpty: {
                        message: 'The labelName is required and cannot be empty'
                    }
                }
            }
        }
    }).on('success.form.bv', function(e) {
        // Prevent form submission
        e.preventDefault();

        // Get the form instance
        var $form = $(e.target);

        // Get the BootstrapValidator instance
        var bv = $form.data('bootstrapValidator');

        // Use Ajax to submit form data
        $.post($form.attr('action'), $form.serialize(), function(result) {
        	if(result.errorCode != 200){
        		alert(result.moreInfo);
        		return;
        	}else
        	  alert(commonSuccess);
        	  window.location.href = location.href;
        }, 'json');
    });

	
});